package cn.ronghuanet.auth.controller;

import cn.ronghuanet.auth.domain.Menu;
import cn.ronghuanet.auth.service.IMenuServiceI;
import cn.ronghuanet.base.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private IMenuServiceI menuService;

    @GetMapping("/tree/{id}")
    public AjaxResult queryMenuTree(@PathVariable("id") Long  id){
        try {
            List<Menu> list = menuService.queryMenuTree(id);
            return AjaxResult.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error(e.getMessage());
        }
    }
}
